import { MyObject,IMyObject } from "./MyObject";
import {Subject,SubjectType,ISubject} from "./Subject";
export interface ITeacher extends IMyObject{
    id:number
    getSubject(type:SubjectType):ISubject | undefined
  getSubTeacher(type:SubjectType) :string

  setSubjectByType(type:SubjectType, subTeacher: string):void
  setSubject(Subject:ISubject):void
}

export class Teacher extends MyObject  implements ITeacher {
    id = 0;
  
    private Subjects: Map<SubjectType,ISubject> = new Map<SubjectType,ISubject>();
  
    constructor(id: number) {
      super();
      this.id = id;
    }
  
    getSubject(type: SubjectType): ISubject | undefined {
      return this.Subjects.get(type);
    }
  
    getSubTeacher(type: SubjectType): string {
      const Subject = this.getSubject(type);
      return Subject ? Subject.toString() : "无"
    }
  
    setSubject(Subject: ISubject): void {
      this.Subjects.set(Subject.type,Subject)
    }
  
    setSubjectByType(type: SubjectType, subTeacher: string): void {
      const subject = new Subject(type,subTeacher);
      this.setSubject(subject)
    }
  
    toString(): string {
      return '班级'+this.id + ":" ;
    }
}